RSpec::Matchers.define :contain_name do |name|
  match do |actual|
    actual = actual[@in] if @in
    actual.select { |element| element['name'] == name }.any?
  end

  chain :in do |key|
    @in = key
  end
end
